package scanner;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import tablaSimbolos.GestorTSimbolos;

import errores.GestorErrores;


/**
 * Clase main de prueba
 * @author Karen Andaziza Oblitas, Elias Boukamza Unsain, Jose Luis Castro Hernando, Juan Piorno Campo, Konstantin Thierbach
 * Dec 7, 2007
 */
public class MainLEx {

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{		
		FileReader fr = null;
		String test = "";
		//TablaSimbolos tabla = new TablaSimbolos();
		GestorTSimbolos gTS=GestorTSimbolos.getInstancia();
		GestorErrores gs = GestorErrores.getInstancia();
		String ficheroprueba= "pruebas\\buenas\\12.pas";
		try
		{
			fr = new FileReader(ficheroprueba);
		}
		catch(FileNotFoundException e) {
			System.out.println("Could not find file!");
		}
		//gTS.creaAmbito();
		AnaLex lex = new AnaLex(fr,gTS,gs);
		//AnaLex lex = new AnaLex(fr,tabla,gs);
		try {
			test = lex.nextToken().toString();
			if(test != null) {
				do {
					System.out.println(test);
					test = lex.nextToken().toString();
				} while (test != "(EOF,no more fun)");
				//System.out.println(test);
			}
			lex.getgTS().muestraTabla();
			lex.getGE().printErrores();
			//lex.getTS().muestraTabla();
			fr.close();
		}
		catch(IOException e) {
			e.printStackTrace();
		}
		try {
			fr = new FileReader(ficheroprueba);
		}
		catch(FileNotFoundException e) {
			System.out.println("Could not find file!");
		}
		//tabla.abreAmbito();
		/*gTS.creaAmbito();
		 lex = new AnaLex(fr,gTS,gs);
		//lex = new AnaLex(fr,tabla,gs);
		try {
			test = lex.nextToken().toString();
			if(test != null) {
				do {
					System.out.println(test);
					test = lex.nextToken().toString();
				} while (test != "(EOF,no more fun)");
				System.out.println(test);
			}
			lex.getgTS().muestraTabla();
			lex.getGE().printErrores();
			//lex.getTS().muestraTabla();
			fr.close();
		}
		catch(IOException e) {
			e.printStackTrace();
		}*/
		
	}

}
